import QtQuick 1.0
import Box2D 1.0

Item {
    id: level1

    Wall {
        id: earth

        height: 500/844*screen.height
        width: spikeMat.x + spikeMat.width - x
        anchors { left: parent.left; top: parent.bottom; topMargin: -80/900*screen.height }
        source: "gfx/grass.png"
    }
    Wall {
        id: ceiling

        height: 20
        anchors { left: parent.left; right: parent.right; bottom: parent.top }
        source: "gfx/grass.png"
    }
    Wall {
        id: leftWall

        width: 20
        anchors { right: parent.left; bottom: ground.top; top: ceiling.bottom }
    }
    Wall {
        id: rightWall

        width: 20
        anchors { left: parent.right; bottom: ground.top; top: ceiling.bottom }
    }

    Ground {
        id: ground

        x: 4100/1500*screen.width
        y: 1.4*screen.height
        width: 3000/1500*screen.width
        height: 100/844*screen.height
    }

    Jump {
        id: start

        x: 0
        y: 1520/900*screen.height
        width: 350/1500*screen.width
        height: 200/844*screen.height
    }

    Jump {
        id: jump

        x: 2*screen.width
        y: 1520/900*screen.height
        width: 350/1500*screen.width
        height: 200/844*screen.height
    }

    Ground {
        id: ground2

        x: ground.x + ground.width*1.4
        y: 0.7*screen.height
        width: 800/1500*screen.width
        height: 100/844*screen.height
    }

    Jump {
        id: jump2

        x: ground.x + ground.width - width
        y: ground.y - height*0.98
        width: 350/1500*screen.width
        height: 200/844*screen.height
    }

    Jump {
        id: jump3

        x: ground.x + width*0.2
        y: ground.y - height*0.98
        width: 350/1500*screen.width
        height: 200/844*screen.height
    }

    SpikeMat {
        x: jump3.x + jump3.width
        y: ground.y - height
        width: jump.width*2
        height: spikeMat.height
    }

    Ground {
        id: ground3

        x: ground2.x + ground2.width*1.8
        y: ground.y*0.7
        width: 4000/1500*screen.width
        height: 100/844*screen.height
        rotation: 45
    }

    Ground {
        id: ground4

        x: ground3.x + ground3.width*Math.cos(ground3.rotation*Math.PI/180)
        y: ground3.y + ground3.width*Math.sin(ground3.rotation*Math.PI/180)
        width: 500/1500*screen.width
        height: 100/844*screen.height
        rotation: 35
    }

    Ground {
        id: ground5

        bodyType: Body.Static
        x: ground4.x + ground4.width*Math.cos(ground4.rotation*Math.PI/180)
        y: ground4.y + ground4.width*Math.sin(ground4.rotation*Math.PI/180)
        width: 500/1500*screen.width
        height: 100/844*screen.height
        rotation: 25

        fixtures: Box {
            anchors.fill: parent
            friction: 0.9
        }
    }

    Ground {
        id: ground6

        x: ground5.x + ground5.width*Math.cos(ground5.rotation*Math.PI/180)
        y: ground5.y + ground5.width*Math.sin(ground5.rotation*Math.PI/180)
        width: 500/1500*screen.width
        height: 100/844*screen.height
        rotation: 15
    }

    Ground {
        id: ground7

        x: ground6.x + ground6.width*Math.cos(ground6.rotation*Math.PI/180)
        y: ground6.y + ground6.width*Math.sin(ground6.rotation*Math.PI/180)
        width: 500/1500*screen.width
        height: 100/844*screen.height
    }

    Ground {
        id: ground8

        x: ground7.x + ground7.width*Math.cos(ground7.rotation*Math.PI/180)
        y: ground7.y + ground7.width*Math.sin(ground7.rotation*Math.PI/180)
        width: 500/1500*screen.width
        height: 100/844*screen.height
        rotation: - 15
    }

    Ground {
        id: ground9

        x: ground8.x + ground8.width*Math.cos(ground8.rotation*Math.PI/180)
        y: ground8.y + ground8.width*Math.sin(ground8.rotation*Math.PI/180)
        width: 500/1500*screen.width
        height: 100/844*screen.height
        rotation: - 45
    }

    Ground {
        id: ground10

        width: 500/1500*screen.width
        height: 100/844*screen.height
        x: ground9.x + ground9.width*Math.cos(ground9.rotation*Math.PI/180)
        y: ground9.y + ground9.width*Math.sin(ground9.rotation*Math.PI/180)
        rotation: - 68
    }

    Ground {
        id: ground11

        x: ground10.x + ground10.width*Math.cos(ground10.rotation*Math.PI/180)*4
        y: ground10.y + ground10.width*Math.sin(ground10.rotation*Math.PI/180)*4.3
        width: 2000/1500*screen.width
        height: 50/844*screen.height
        rotation: 35
    }

    Body {
        id: finish

        bodyType: Body.Static
        parent: world
        width: 100
        height: 150
        //x: jump.x + jump.width
        //y: jump.y - height
        //x: ground2.x + ground2.width - width/4
        //y: ground2.y - height
        x: ground11.x + ground11.width*Math.cos(ground11.rotation*Math.PI/180)
        y: ground11.y + ground11.width*Math.sin(ground11.rotation*Math.PI/180) - height

        fixtures: Box {
            anchors.fill: parent
            friction: 0.9
            onBeginContact: screen.finish();
        }

        Image {
            anchors.fill: parent
            source: "gfx/finish.png"
        }
    }

    SpikeMat {
        id: spikeMat

        x: jump.x + jump.width*2
        y: jump.y + (jump.height-height)
        width: ground3.x+ground3.width/5.8-x
        height: jump.height/2
    }
}
